﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ServiceImplementation.Translator
{
    /// <summary>
    /// Define UserDTO Translator
    /// </summary>
   public class UserDTOTranslator
    {
       /// <summary>
        /// To Translate UserDTO to UserBusinessEntity
       /// </summary>
       /// <param name="userDTO"></param>
       /// <returns></returns>
        public static BLL.User TranslateDTOToBusiness(DataContracts.UserDTO userDTO)
        {
            BLL.User User = new BLL.User();
            User.UserId = userDTO.UserId;
            User.FirstName = userDTO.FirstName;
            User.LastName = userDTO.LastName;
            //User.Department = Translator.DepartmentDTOTranslator.TranslateDTOToBusiness(userDTO.Department);
            //User.Role = Translator.RoleDTOTranslator.TranslateDTOToBusiness(userDTO.Role);
            //User.Role.Status = Translator.StatusDTOTranslator.TranslateDTOToBusiness(userDTO.Role.Status);
            BLL.Department Department= new BLL.Department();
            Department.DepartmentId = userDTO.Department.DepartmentId;
            Department.DepartmentName = userDTO.Department.DepartmentName;
            User.Department = Department;

            BLL.Role Role= new BLL.Role();
            Role.RoleId = userDTO.Role.RoleId;
            Role.RoleName = userDTO.Role.RoleName;
            BLL.Status Status = new BLL.Status();
            Status.StatusId = userDTO.Role.Status.StatusId;
            Status.StatusName = userDTO.Role.Status.StatusName;
            Role.Status = Status;
            User.Role = Role;

            return User;
        }
       /// <summary>
        /// To Translate UserBusinessEntity to UserDTO
       /// </summary>
       /// <param name="user"></param>
       /// <returns></returns>
        public static DataContracts.UserDTO TranslateBusinessToDTO(BLL.User user)
        {
            DataContracts.UserDTO UserDTO = new DataContracts.UserDTO();
            UserDTO.UserId = user.UserId;
            UserDTO.FirstName = user.FirstName;
            UserDTO.LastName = user.LastName;
            UserDTO.Department = Translator.DepartmentDTOTranslator.TranslateBusinessToDTO(user.Department);
            UserDTO.Role = new DataContracts.RoleDTO();
            UserDTO.Role.RoleId = user.Role.RoleId;
            UserDTO.Role.RoleName = user.Role.RoleName;
            return UserDTO;
        }
        public static BLL.User TranslateDTOToBusinessView(DataContracts.UserDTO userDTO)
        {
            BLL.User User = new BLL.User();
            User.UserId = userDTO.UserId;
            User.FirstName = userDTO.FirstName;
            User.LastName = userDTO.LastName;
            User.Department = new BLL.Department();
            User.Department.DepartmentId = userDTO.Department.DepartmentId;
            User.Department.DepartmentName = userDTO.Department.DepartmentName;
            User.Role = new BLL.Role();
            User.Role.RoleId = userDTO.Role.RoleId;
            User.Role.RoleName = userDTO.Role.RoleName;
            return User;
        }
        public static DataContracts.UserDTO TranslateBusinessToDTOView(BLL.User user)
        {
            DataContracts.UserDTO UserDTO = new DataContracts.UserDTO();
            UserDTO.UserId = user.UserId;
            UserDTO.FirstName = user.FirstName;
            UserDTO.LastName = user.LastName;
            UserDTO.Department = new DataContracts.DepartmentDTO();
            UserDTO.Department.DepartmentId = user.Department.DepartmentId;
            UserDTO.Department.DepartmentName = user.Department.DepartmentName;
            UserDTO.Role = new DataContracts.RoleDTO();
            UserDTO.Role.RoleId = user.Role.RoleId;
            UserDTO.Role.RoleName = user.Role.RoleName;
            return UserDTO;
        }
    }
}
